package com.logistics.service.Impl;

import com.logistics.dao.BaseDao;
import com.logistics.dao.VehicleDao;
import com.logistics.entity.Vehicle;
import com.logistics.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Ranger on 2015/8/14.
 */
@Service
public class VehicleServiceImpl extends BaseServiceImpl<Vehicle> implements VehicleService {
    @Autowired
    private VehicleDao vehicleDao;

    @Override
    public BaseDao getBaseDao() {
        return vehicleDao;
    }

    /**
     * 新增车辆
     */
    public Integer addVehicle(Vehicle vehicle) {
        // 检测用户输入的车辆信息
        if (vehicle.getIdentity().isEmpty()) {
            return null;
        } else {
            return vehicleDao.save(vehicle);
        }
    }

    /**
     * 修改车辆信息
     */
    public Integer alterVehicleInfo(Vehicle vehicle) {
        if (vehicle.getIdentity().isEmpty()) { // 检测用户输入
            return null;
        }else {
            return vehicleDao.save(vehicle);
        }
    }
}
